<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.js"></script> 

  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.1.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">


<link rel="stylesheet" href="/blog/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"linzhuangrong.gitee.io","root":"/blog/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="Redis Cluster在线迁移">
<meta property="og:type" content="article">
<meta property="og:title" content="Redis Cluster在线迁移">
<meta property="og:url" content="https://linzhuangrong.gitee.io/blog/2019/09/15/redis-cluster5%20-%203/index.html">
<meta property="og:site_name" content="Rong的博客">
<meta property="og:description" content="Redis Cluster在线迁移">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://oscimg.oschina.net/oscnet/up-6719d1b81708c6f76cd49deeda1d2c2d29d.png">
<meta property="og:image" content="https://oscimg.oschina.net/oscnet/up-b8851cdd44884b6e0f4f7cb7c3bb21b428d.png">
<meta property="article:published_time" content="2019-09-14T16:00:00.000Z">
<meta property="article:modified_time" content="2020-08-31T15:51:56.908Z">
<meta property="article:author" content="林壮荣">
<meta property="article:tag" content="Redis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://oscimg.oschina.net/oscnet/up-6719d1b81708c6f76cd49deeda1d2c2d29d.png">

<link rel="canonical" href="https://linzhuangrong.gitee.io/blog/2019/09/15/redis-cluster5%20-%203/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Redis Cluster在线迁移 | Rong的博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Rong的博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/blog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://linzhuangrong.gitee.io/blog/2019/09/15/redis-cluster5%20-%203/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="林壮荣">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Rong的博客">
    </span>
      <header class="post-header">
	  
        <h1 class="post-title" itemprop="name headline">
          Redis Cluster在线迁移
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-09-15 00:00:00" itemprop="dateCreated datePublished" datetime="2019-09-15T00:00:00+08:00">2019-09-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-08-31 23:51:56" itemprop="dateModified" datetime="2020-08-31T23:51:56+08:00">2020-08-31</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/%E9%9B%86%E7%BE%A4%E6%9C%8D%E5%8A%A1/" itemprop="url" rel="index"><span itemprop="name">集群服务</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/%E9%9B%86%E7%BE%A4%E6%9C%8D%E5%8A%A1/Redis/" itemprop="url" rel="index"><span itemprop="name">Redis</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <div class="post-description">Redis Cluster在线迁移</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Redis-Cluster在线迁移"><a href="#Redis-Cluster在线迁移" class="headerlink" title="Redis Cluster在线迁移"></a>Redis Cluster在线迁移</h1><p>前言</p>
<p>Redis是一个开源的高性能键值对数据库。它通过提供多种键值数据类型来适应不同场景下的存储需求，并借助许多高层级的接口使其可以胜任如缓存、队列系统等不同的角色。<br>Redis持久化了解<br>为了让性能更加优异，Redis默认是把所有的数据都存在内存中的。但是当服务器重启或程序异常崩溃时，Redis的数据就会全部丢失。因此出现了持久化的概念。持久化就是将存在内存中的数据同步到磁盘来保证持久化。</p>
<blockquote>
<p>1、Redis持久化的方式<br>两种： RDB 和 AOF<br>RDB 持久化可以在指定的时间间隔内生成数据集的时间点快照（point-in-time snapshot）。<br>AOF 持久化记录服务器执行的所有写操作命令，并在服务器启动时，通过重新执行这些命令来还原数据集。 AOF 文件中的命令全部以 Redis 协议的格式来保存，新命令会被追加到文件的末尾。 Redis 还可以在后台对 AOF 文件进行重写（rewrite），使得 AOF 文件的体积不会超出保存数据集状态所需的实际大小。<br>2、持久化的数据有什么用？<br>用于重启后的数据恢复。Redis是一个内存数据库，无论是RDB还是AOF，都只是其保证数据恢复的措施；所以Redis在利用RDB和AOF进行恢复的时候，都会读取RDB或AOF文件，重新加载到内存中。<br>默认持久化了解<br>其中RDB就是point-in-time snapshot快照存储，也是默认的持久化方式。对于RDB可理解为半持久化模式，即按照一定的策略周期性的将数据保存到磁盘。对应产生的数据文件为dump.rdb，通过配置文件中的save参数来定义快照的周期。Redis的RDB文件不会坏掉，因为其写操作是在一个新进程中进行的。</p>
</blockquote>
<h1 id="一、准备工作"><a href="#一、准备工作" class="headerlink" title="一、准备工作"></a>一、准备工作</h1><p>默认的持久化设置：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">save 900 1                          #当有一条Keys数据被改变时，900秒刷新到Disk一次</span><br><span class="line">save 300 10                        #当有10条Keys数据被改变时，300秒刷新到Disk一次</span><br><span class="line">save 60 10000                    #当有10000条Keys数据被改变时，60秒刷新到Disk一次</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>利用持久化迁移数据，下面操作在所有主节点执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">##########查看配置信息及当前存储的key值###########</span><br><span class="line">[root@localhost ~]# redis-cli -c -h 10.10.10.10 -p 6379</span><br><span class="line"></span><br><span class="line">#########保存最新的key值################</span><br><span class="line">redis 10.10.10.10:6379&gt; BGSAVE</span><br><span class="line">Background saving started</span><br><span class="line">##########查看是否保存成功##############</span><br><span class="line">redis 10.10.10.10:6379&gt; LASTSAVE</span><br><span class="line">(integer) 1420367903</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>Redis–BGSAVE<br>在后台异步(Asynchronously)保存当前数据库的数据到磁盘。BGSAVE 命令执行之后立即返回 OK ，然后 Redis fork 出一个新子进程，原来的 Redis 进程(父进程)继续处理客户端请求，而子进程则负责将数据保存到磁盘，然后退出。<br>LASTSAVE<br>返回最近一次 Redis 成功将数据保存到磁盘上的时间，以 UNIX 时间戳格式表示。</p>
<p>转换Unix时间戳的网址<br><a target="_blank" rel="noopener" href="http://tool.chinaz.com/Tools/unixtime.aspx">http://tool.chinaz.com/Tools/unixtime.aspx</a></p>
<h1 id="二、安装部署redis-migrate-tool"><a href="#二、安装部署redis-migrate-tool" class="headerlink" title="二、安装部署redis-migrate-tool"></a>二、安装部署redis-migrate-tool</h1><p>官方链接：<a target="_blank" rel="noopener" href="https://github.com/vipshop/redis-migrate-tool">https://github.com/vipshop/redis-migrate-tool</a><br>软件编译安装：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">mkdir &#x2F;opt&#x2F;cachecloud&#x2F;  &amp;&amp; cd &#x2F;opt&#x2F;cachecloud&#x2F;</span><br><span class="line">wget https:&#x2F;&#x2F;github.com&#x2F;vipshop&#x2F;redis-migrate-tool&#x2F;archive&#x2F;master.zip</span><br><span class="line">unzip master.zip</span><br><span class="line">mv redis-migrate-tool-master redis-migrate-tool</span><br><span class="line">cd redis-migrate-tool</span><br><span class="line">mkdir data</span><br><span class="line">autoreconf -fvi</span><br><span class="line">.&#x2F;configure</span><br><span class="line">make</span><br><span class="line">src&#x2F;redis-migrate-tool -h</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="三、配置启动redis-migrate-tool"><a href="#三、配置启动redis-migrate-tool" class="headerlink" title="三、配置启动redis-migrate-tool"></a>三、配置启动redis-migrate-tool</h1><p>3.1）配置文件实例：<br><code>vim /opt/cachecloud/redis-migrate-tool/rmt.conf</code></p>
<p>示例1：从rdb文件恢复数据到redis cluster集群</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">[source]</span><br><span class="line">type: rdb file</span><br><span class="line">servers:</span><br><span class="line"> - &#x2F;data&#x2F;redis&#x2F;dump1.rdb</span><br><span class="line"> - &#x2F;data&#x2F;redis&#x2F;dump2.rdb</span><br><span class="line"> - &#x2F;data&#x2F;redis&#x2F;dump3.rdb</span><br><span class="line"></span><br><span class="line">[target]</span><br><span class="line">type: redis cluster</span><br><span class="line">servers:</span><br><span class="line"> - 127.0.0.1:7379</span><br><span class="line"></span><br><span class="line">[common]</span><br><span class="line">listen: 0.0.0.0:8888</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>示例2：从redis cluster集群迁移数据到另外一个cluster集群</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[source]</span><br><span class="line">type: redis cluster</span><br><span class="line">servers:</span><br><span class="line">- 127.0.0.1:8379</span><br><span class="line"></span><br><span class="line">[target]</span><br><span class="line">type: redis cluster</span><br><span class="line">servers:</span><br><span class="line">- 127.0.0.1:7379</span><br><span class="line"></span><br><span class="line">[common]</span><br><span class="line">listen: 0.0.0.0:8888</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>示例3：从redis cluster集群迁移数据到twemproxy集群</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">[source]</span><br><span class="line">type: redis cluster</span><br><span class="line">servers:</span><br><span class="line">- 127.0.0.1:6379</span><br><span class="line"></span><br><span class="line">[target]</span><br><span class="line">type: twemproxy</span><br><span class="line">hash: fnv1a_64</span><br><span class="line">hash_tag: &quot;&#123;&#125;&quot;</span><br><span class="line">distribution: ketama</span><br><span class="line">servers:</span><br><span class="line">- 127.0.0.1:6380:1 server1</span><br><span class="line">- 127.0.0.1:6381:1 server2</span><br><span class="line">- 127.0.0.1:6382:1 server3</span><br><span class="line">- 127.0.0.1:6383:1 server4</span><br><span class="line"></span><br><span class="line">[common]</span><br><span class="line">listen: 0.0.0.0:34345</span><br><span class="line">threads: 8</span><br><span class="line">step: 1</span><br><span class="line">mbuf_size: 512</span><br><span class="line">source_safe: true</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>3.2）软件运行：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd &#x2F;opt&#x2F;cachecloud&#x2F;redis-migrate-tool</span><br><span class="line">src&#x2F;redis-migrate-tool -c rmt.conf -o log -d</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>3.3）状态查看：通过redis-cli连接redis-migrate-tool监控的端口，运行info命令</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">$redis-cli -h 127.0.0.1 -p 8888</span><br><span class="line">127.0.0.1:8888&gt; info</span><br><span class="line"># Server</span><br><span class="line">version:0.1.0</span><br><span class="line">os:Linux 2.6.32-573.12.1.el6.x86_64 x86_64</span><br><span class="line">multiplexing_api:epoll</span><br><span class="line">gcc_version:4.4.7</span><br><span class="line">process_id:9199</span><br><span class="line">tcp_port:8888</span><br><span class="line">uptime_in_seconds:1662</span><br><span class="line">uptime_in_days:0</span><br><span class="line">config_file:&#x2F;ect&#x2F;rmt.conf</span><br><span class="line"></span><br><span class="line"># Clients</span><br><span class="line">connected_clients:1</span><br><span class="line">max_clients_limit:100</span><br><span class="line">total_connections_received:3</span><br><span class="line"></span><br><span class="line"># Memory</span><br><span class="line">mem_allocator:jemalloc-4.0.4</span><br><span class="line"></span><br><span class="line"># Group</span><br><span class="line">source_nodes_count:32</span><br><span class="line">target_nodes_count:48</span><br><span class="line"></span><br><span class="line"># Stats</span><br><span class="line">all_rdb_received:1</span><br><span class="line">all_rdb_parsed:1</span><br><span class="line">rdb_received_count:32</span><br><span class="line">rdb_parsed_count:32</span><br><span class="line">total_msgs_recv:7753587</span><br><span class="line">total_msgs_sent:7753587</span><br><span class="line">total_net_input_bytes:234636318</span><br><span class="line">total_net_output_bytes:255384129</span><br><span class="line">total_net_input_bytes_human:223.77M</span><br><span class="line">total_net_output_bytes_human:243.55M</span><br><span class="line">total_mbufs_inqueue:0</span><br><span class="line">total_msgs_outqueue:0</span><br><span class="line">127.0.0.1:8888&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>3.4）数据校验：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">$src&#x2F;redis-migrate-tool -c rmt.conf -o log -C redis_check</span><br><span class="line">Check job is running...</span><br><span class="line"></span><br><span class="line">Checked keys: 1000</span><br><span class="line">Inconsistent value keys: 0</span><br><span class="line">Inconsistent expire keys : 0</span><br><span class="line">Other check error keys: 0</span><br><span class="line">Checked OK keys: 1000</span><br><span class="line"></span><br><span class="line">All keys checked OK!</span><br><span class="line">Check job finished, used 1.041s</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="附加工具：redis-port"><a href="#附加工具：redis-port" class="headerlink" title="附加工具：redis-port"></a>附加工具：redis-port</h1><p>安装go：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">wget https:&#x2F;&#x2F;dl.google.com&#x2F;go&#x2F;go1.7.5.linux-amd64.tar.gz</span><br><span class="line">tar zxvf go1.7.5.linux-amd64.tar.gz</span><br><span class="line">mv go &#x2F;usr&#x2F;local&#x2F;</span><br><span class="line">mkdir $HOME&#x2F;work</span><br><span class="line">echo &#39;export GOROOT&#x3D;&#x2F;usr&#x2F;local&#x2F;go&#39; &gt;&gt;&#x2F;etc&#x2F;profile </span><br><span class="line">echo &#39;export PATH&#x3D;$PATH:$GOROOT&#x2F;bin&#39; &gt;&gt;&#x2F;etc&#x2F;profile</span><br><span class="line">echo &#39;export GOPATH&#x3D;$HOME&#x2F;work&#39; &gt;&gt;&#x2F;etc&#x2F;profile</span><br><span class="line">source &#x2F;etc&#x2F;profile</span><br><span class="line"># go version</span><br><span class="line">go version go1.7.5 linux&#x2F;amd64</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>下载 redis-port</p>
<p><a target="_blank" rel="noopener" href="http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/66008/cn_zh/1522293930203/redis-port.redis-port?spm=a2c4g.11186623.2.4.hUAhx7&file=redis-port.redis-port">redis-port地址</a><br><strong>使用示例1</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;redis-port  restore  --input&#x3D;x&#x2F;dump.rdb  --target&#x3D;dst_host:dst_port   --auth&#x3D;dst_password  </span><br><span class="line">[--filterkey&#x3D;&quot;str1|str2|str3&quot;] [--targetdb&#x3D;DB] [--rewrite] [--bigkeysize&#x3D;SIZE] [--logfile&#x3D;REDISPORT.LOG]</span><br><span class="line">参数说明</span><br><span class="line"></span><br><span class="line">x&#x2F;dump.rdb : 自建 redis 的 dump 文件路径</span><br><span class="line">dst_host : 目的数据库 redis 域名</span><br><span class="line">dst_port : 目的数据库 redis 端口</span><br><span class="line">dst_password : 目的数据库 redis 密码</span><br><span class="line">str1|str2|str3 : 过滤具有 str1 或 str2 或 str3 的 key</span><br><span class="line">DB : 将要同步入目的数据库 redis 的 DB</span><br><span class="line">rewrite : 覆盖已经写入的 key</span><br><span class="line">bigkeysize&#x3D;SIZE : 当写入的 value 大于 SIZE 时，走大 key 写入模式</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><strong>根据 redis-port 日志查看数据同步状态</strong></p>
<p>根据redis-port日志查看同步状态<br><img src="https://oscimg.oschina.net/oscnet/up-6719d1b81708c6f76cd49deeda1d2c2d29d.png"></p>
<p><strong>根据 redis-port 日志查看数据同步状态</strong></p>
<p>当出现restore: rdb done时数据同步完成。</p>
<p><strong>使用示例2</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;redis-port  sync  --from&#x3D;src_host:src_port --password&#x3D;src_password  --target&#x3D;dst_host:dst_port   </span><br><span class="line">--auth&#x3D;dst_password  [--filterkey&#x3D;&quot;str1|str2|str3&quot;] [--targetdb&#x3D;DB] [--rewrite] [--bigkeysize&#x3D;SIZE] </span><br><span class="line">[--logfile&#x3D;REDISPORT.LOG]</span><br><span class="line">参数说明</span><br><span class="line"></span><br><span class="line">src_host : 自建 redis 域名（或者 IP）</span><br><span class="line">src_port : 自建 redis 端口</span><br><span class="line">src_password : 自建 redis 密码</span><br><span class="line">dst_host : 目的数据库 redis 域名</span><br><span class="line">dst_port : 目的数据库 redis 端口</span><br><span class="line">dst_password : 目的数据库 redis 密码</span><br><span class="line">str1|str2|str3 : 过滤具有 str1 或 str2 或 str3 的 key</span><br><span class="line">DB : 将同步入目的 redis 的 DB</span><br><span class="line">rewrite : 覆盖已经写入的 key</span><br><span class="line">bigkeysize&#x3D;SIZE : 当写入的 value 大于 SIZE 时，走大 key 写入模式</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>根据 redis-port 日志查看数据同步状态<br><img src="https://oscimg.oschina.net/oscnet/up-b8851cdd44884b6e0f4f7cb7c3bb21b428d.png"></p>
<p>根据redis-port日志查看同步状态当出现sync rdb done时全量同步完成，进入增量同步的模式</p>

    </div>

    
    
    
 
    <div>
      
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/blog/2019/09/15/redis-cluster5%20-%203/">Redis Cluster在线迁移</a></p>
  <p><span>文章作者:</span><a href="/" title="访问  的个人博客"></a></p>
  <p><span>发布时间:</span>2019年09月15日 - 00:09</p>
  <p><span>最后更新:</span>2020年08月31日 - 23:08</p>
  <p><span>原始链接:</span><a href="/blog/2019/09/15/redis-cluster5%20-%203/" title="Redis Cluster在线迁移">https://linzhuangrong.gitee.io/blog/2019/09/15/redis-cluster5%20-%203/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://linzhuangrong.gitee.io/blog/2019/09/15/redis-cluster5%20-%203/"  aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
    $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
    });
    });  
</script>


      
    </div>

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/blog/tags/Redis/" rel="tag"># Redis</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/blog/2019/09/15/redis-cluster5/" rel="prev" title="centos7部署redis5-cluster集群">
      <i class="fa fa-chevron-left"></i> centos7部署redis5-cluster集群
    </a></div>
      <div class="post-nav-item">
    <a href="/blog/2019/09/15/redis-cluster5%20-%202/" rel="next" title="Redis支持三种集群方案">
      Redis支持三种集群方案 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Redis-Cluster%E5%9C%A8%E7%BA%BF%E8%BF%81%E7%A7%BB"><span class="nav-number">1.</span> <span class="nav-text">Redis Cluster在线迁移</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="nav-number">2.</span> <span class="nav-text">一、准备工作</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2redis-migrate-tool"><span class="nav-number">3.</span> <span class="nav-text">二、安装部署redis-migrate-tool</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E9%85%8D%E7%BD%AE%E5%90%AF%E5%8A%A8redis-migrate-tool"><span class="nav-number">4.</span> <span class="nav-text">三、配置启动redis-migrate-tool</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E9%99%84%E5%8A%A0%E5%B7%A5%E5%85%B7%EF%BC%9Aredis-port"><span class="nav-number">5.</span> <span class="nav-text">附加工具：redis-port</span></a></li></ol></div>
      </div>
      <!--/noindex-->
    
           <div>
            <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=144301&auto=1&height=66"></iframe>
           </div>
   
      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">林壮荣</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">20</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/blog/categories/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/blog/tags/">
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">林壮荣</span>
</div>
<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共31.2k字</span>
</div>

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<div class="powered-by">
  <i class="fa fa-user-md"></i>
  <span id="busuanzi_container_site_pv">
    本站访问量:<span id="busuanzi_value_site_pv"></span>次
  </span>
  <span class="post-meta-divider">|</span>
  <span id="busuanzi_container_site_uv">
    本站总访客量：<span id="busuanzi_value_site_uv"></span>人
  </span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>




  




  
<script src="/blog/js/local-search.js"></script>













  

  

</body>
</html>
